package com.d3works.csv.script;

import com.d3works.apps.stock.db.StockMove;
import com.d3works.apps.stock.service.StockMoveService;
import com.d3works.apps.stock.service.StockMoveToolService;
import com.d3works.exception.D3worksException;
import com.google.inject.Inject;
import java.util.Map;

public class ImportStockMove {

  protected StockMoveToolService stockMoveToolService;
  protected StockMoveService stockMoveService;

  @Inject
  public ImportStockMove(
      StockMoveToolService stockMoveToolService, StockMoveService stockMoveService) {
    this.stockMoveToolService = stockMoveToolService;
    this.stockMoveService = stockMoveService;
  }

  public Object importAddressStr(Object bean, Map<String, Object> values) {
    assert bean instanceof StockMove;

    StockMove stockMove = (StockMove) bean;
    stockMoveToolService.computeAddressStr(stockMove);
    return stockMove;
  }

  public Object importStockMove(Object bean, Map<String, Object> values) throws D3worksException {
    assert bean instanceof StockMove;

    StockMove stockMove = (StockMove) bean;
    stockMoveService.plan(stockMove);
    return stockMove;
  }
}
